package com.explorx.sns.puma.im.core.chat.consts;

import java.util.Arrays;
import java.util.Optional;

public enum GroupFiledPrivilegeEnum {
    GROUP_NAME(0,GroupMemberRoleEnum.MANAGER),
    GROUP_NOTICE(1,GroupMemberRoleEnum.MANAGER),


    GROUP_NICK_NAME(10,GroupMemberRoleEnum.MEMBER),
    GROUP_REMARK(11,GroupMemberRoleEnum.MEMBER),

    UNKONWN(99,GroupMemberRoleEnum.OWNER)
    ;

    GroupFiledPrivilegeEnum(int attributeId, GroupMemberRoleEnum minRoleNeed) {
        this.attributeId = attributeId;
        this.minRoleNeed = minRoleNeed;
    }

    public static GroupFiledPrivilegeEnum findById(int filedId){
        final Optional<GroupFiledPrivilegeEnum> any = Arrays.stream(GroupFiledPrivilegeEnum.values()).filter(ele -> ele.getAttributeId() == filedId).findAny();
        return any.isPresent() ?any.get() :UNKONWN;
    }

    public int getAttributeId() {
        return attributeId;
    }

    public GroupMemberRoleEnum getMinRoleNeed() {
        return minRoleNeed;
    }

    private int attributeId;

    private GroupMemberRoleEnum minRoleNeed;
}
